/<template>
<div>
    <van-form @submit="onSubmit">
    <van-field
        v-model="user" name="user" label="用户名" placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
    />
    <van-field
        v-model="Euser" name="Euser" label="账户" placeholder="账户"
        :rules="[{ required: true, message: '请填写账户' }]"
    />
    <van-field
        v-model="sex" name="sex" label="性别" placeholder="性别"
        :rules="[{ required: true, message: '请填写性别' }]"
    />
    <van-field
        v-model="date" name="date" label="最后时间" placeholder="最后时间"
        :rules="[{ required: true, message: '请填写最后时间' }]"
    />
    
    <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">确定编辑</van-button>
    </div>
    </van-form>
</div>
</template>

<script>
export default {
    data() {
        return {
            user: '',
            Euser: '',
            sex:'',
            date:'',
            // obj:{},
        };
    },
    mounted() {
        console.log(this.$route.params.id);
        console.log(this.$store.state.AllList);
        this.$store.state.AllList.forEach((item,index) => {
            if(item.id == this.$route.params.id) {
                // this.obj = item;
                this.user = item.user;
                this.Euser = item.Euser;
                this.sex = item.sex;
                this.date = item.date;
            }
            // console.log(this.obj);
        });
    },
    methods: {
        onSubmit(values) {
            console.log('submit', values);
            values.id = this.$route.params.id;
            this.$store.commit('onSubmit', values);
            this.$router.back()
        },
    },
}
</script>

<style>
.van-form{
    width: 300px;
}
</style>